package cn.zqh.brand.controller;


import cn.zqh.bean.api.CommonResult;
import cn.zqh.bean.bo.Brand;
import cn.zqh.bean.bo.CreateABrandParams;
import cn.zqh.brand.client.CommodityClient;
import cn.zqh.brand.service.BrandService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author zqh
 * @since 2023-01-12
 */
@RestController
@RequestMapping("/brand")
public class BrandController {


    @Autowired
    private BrandService brandService;

    /**
     * @Author: zqh
     * @Date:
     * @Description: 创建一个新品牌
     */
    @ApiOperation(value = "添加一个新的品牌")
    @PostMapping("CreateANewBrand")
    public CommonResult CreateANewBrand(@RequestBody CreateABrandParams createABrandParams) {
        return brandService.CreateANewBrand(createABrandParams);
    }

    /**
     * @Author: zqh
     * @Date:
     * @Description: 根据id删除品牌
     */
    @ApiOperation(value = "根据id删除品牌")
    @DeleteMapping("DelBrandById")
    public CommonResult DelBrandById(Integer id) {
        return brandService.DelBrandById(id);
    }


    /**
     * @Author: zqh
     * @Date:
     * @Description: 根据id查询品牌信息
     */
    @ApiOperation(value = "根据id查询品牌信息")
    @GetMapping("getBrandById")
    public CommonResult getBrandById(Integer id) {
        return brandService.getBrandById(id);
    }

    /**
     * @Author: zqh
     * @Date:
     * @Description: 修改品牌信息
     */
    @ApiOperation(value = "修改品牌信息")
    @PostMapping("UpdateBrandMation")
    public CommonResult UpdateBrandMation(Integer id, String avatar, String brandName) {
        return brandService.UpdateBrandMation(id, avatar, brandName);
    }

    /**
     * @Author: zqh
     * @Date:
     * @Description: 查询所有品牌
     */
    @ApiOperation(value = "查询所有品牌")
    @GetMapping("getALlBrand")
    public CommonResult getAllBrand(Integer page, Integer size) {
        return brandService.getAllBrand(page, size);
    }

    /**
     * @Author: zqh
     * @Date:
     * @Description: 查询被删除了的品牌
     */
    @ApiOperation(value = "查询被删除了的品牌")
    @GetMapping("/getDelBrand")
    public CommonResult getDelBrand(Integer page, Integer size) {
        return brandService.getDelBrand(page, size);
    }

    /**
     * @Author: zqh
     * @Date:
     * @Description: 把被删除了的品牌取消删除
     */
    @ApiOperation(value = "把被删除了的品牌取消删除")
    @PostMapping("cancelBrand")
    public CommonResult cancelBrand(Integer id) {
        return brandService.cancelBrand(id);
    }

    /**
      * @Author: zqh
      * @Date:
      * @Description: 查询所有品牌的数量
    */
    @ApiOperation(value = "查询所有品牌的数量")
    @GetMapping("getBrandNumber")
    public CommonResult getBrandNumber(){
        return brandService.getBrandNumber();
    }

}

